package com.wooming.myserver.util;

import com.wooming.myserver.dto.GameStatusDTO;

import static java.lang.Math.pow;

/**
 * 模块升级消耗记录工具类
 *
 * @author Wooming 2025/05/27
 */
public record Cost(int goldCost, int actionCost) {

    public static Cost getCost(GameStatusDTO ModuleStatus, GameStatusDTO FrameworkStatus) {
        int goldCost = (int) (1000 + pow(ModuleStatus.getCurrentLevel(), 2) * 1000);
        int actionCost = (int) (2 + pow(ModuleStatus.getCurrentLevel(), 2));
        double discount = 1;
        if (FrameworkStatus.getCurrentLevel() <= 50) {// 框架优化等级折扣,最多半折
            discount -= 0.01 * FrameworkStatus.getCurrentLevel();
        } else {
            discount -= 0.01 * 50;
        }
        goldCost = (int) (goldCost * discount);
        actionCost = (int) (actionCost * discount);
        return new Cost(goldCost, actionCost);
    }
}
